public class LemonadeChange {
    public boolean lemonadeChange(int[] bills) {
        int five = 0, ten = 0;
        for(int x : bills) {
            if(x == 5) {
                five++;
            }else if(x == 10) {
                // 付10元, 找 5 元零钱, 没有说明无法找零
                if(five == 0) {
                    return false;
                }
                five--;
                ten++;
            }else {
                // 20
                if(five >= 1 && ten >= 1) {
                    five--;
                    ten--;
                }else if(five >= 3) {
                    five -= 3;
                }else {
                    return false;
                }
            }
        }
        return true;
    }
}
